'use strict';

module.exports = () => {
  return async (ctx, next) => {
    const { app, socket, logger, helper } = ctx;
    const id = socket.id;
    const query = socket.handshake.query;

    // 用户信息
    const { room, userId } = query;
    console.log('query: ', query);

    socket.emit('connected', { time: Date.now(), data: { room, userId, id } });
    socket.join(room);

    await next();
  };
};
